activate
Activates the Widevine component and updates it to the latest version if it is available.
The Widevine component files are stored in the user data directory of the engine.
On Windows and macOS, you can activate Widevine without specifying a custom user data directory. There's no need to restart the engine after first activation or update, as the changes are applied automatically.
On Linux, you must specify a custom user data directory to activate Widevine. It is required due to the way Widevine is implemented on Linux. When the component is activated for the first time, or it is updated to the latest version during activation, the engine must be restarted to apply the changes.
Here is an example of how to specify a custom user data directory and restart the engine if it is required:
var options = EngineOptions.newBuilder(HARDWARE_ACCELERATED)
// Specify a custom user data directory.
.userDataDir(Paths.get("path/to/user/data/dir"))
.build();
Engine engine = Engine.newInstance(options);
// Activate Widevine and restart the engine if necessary.
var status = engine.widevine().activate().join();
if (status == WidevineActivationStatus.RESTART_REQUIRED) {
// Restart the engine with the same options.
engine.close();
engine = Engine.newInstance(options);
}
Browser browser = engine.newBrowser();
Return
the status of the Widevine activation
See also
Throws
when the Widevine component is being activated on Linux without a custom user data directory
if the engine is closed